﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using fcwms.Common;

public partial class admin_storage_store_list : SessionManage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            RptBind();
        }
    }

    #region 数据绑定==============================
    public void RptBind()
    {
        fcwms.BLL.dt_storage bll = new fcwms.BLL.dt_storage();
        DataSet ds = bll.GetList("");
        this.AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;  //DataView的Count属性,AspNetPager的RecordCount属性.
        PagedDataSource pds = new PagedDataSource();
        pds.AllowPaging = true;                                   //启用分页.
        pds.PageSize = AspNetPager1.PageSize;                     //每页要显示的记录条数.      
        pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; //当前页索引.
        pds.DataSource = ds.Tables[0].DefaultView;                //分页数据源以DataView为数据源.  
        lblCount.Text = AspNetPager1.RecordCount.ToString();      //总共几条数据
        rptList.DataSource = pds;
        rptList.DataBind();
    }

    #region 返回仓库状态======================
    protected string GetStorageStatus(int storage)
    {
        string str = "";
        switch (storage)
        {
            case 0:
                str = "空闲";
                break;
            case 1:
                str = "正在入库";
                break;
            default:
                str = "正在出库";
                break;
        }
        return str;
    }
    #endregion

    //protected void ddlNum_SelectedIndexChanged1(object sender, EventArgs e)
    //{
    //    AspNetPager1.CurrentPageIndex = 1;
    //    AspNetPager1.PageSize = Convert.ToInt32(ddlNum.Text.Trim());
    //    RptBind();
    //}
    protected void btn10_Click(object sender, EventArgs e)
    {
        AspNetPager1.CurrentPageIndex = 1;
        AspNetPager1.PageSize = 10;
        RptBind();
    }
    protected void btn20_Click(object sender, EventArgs e)
    {
        AspNetPager1.CurrentPageIndex = 1;
        AspNetPager1.PageSize = 20;
        RptBind();
    }
    protected void btn50_Click(object sender, EventArgs e)
    {
        AspNetPager1.CurrentPageIndex = 1;
        AspNetPager1.PageSize = 1;
        RptBind();
    }
    //protected void selNum_ServerChange(object sender, EventArgs e)
    //{
    //    AspNetPager1.CurrentPageIndex = 1;
    //    AspNetPager1.PageSize = Convert.ToInt32(this.selNum.Value.ToString());
    //    RptBind();
    //    //Response.Write(ab.Value);

    //}
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        RptBind();
    }
    #endregion

    #region 删除操作==============================
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        //ChkAdminLevel("sys_branch", ActionEnum.Delete.ToString()); //检查权限
        fcwms.BLL.dt_storage bll = new fcwms.BLL.dt_storage();
        for (int i = 0; i < rptList.Items.Count; i++)
        {
            int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
            CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
            if (cb.Checked)
            {
                bll.Delete(id);
            }
        }
        MessageBox.Jscript(this, "批量删除成功啦", "store_list.aspx", "Success");
    }
    #endregion


}